package huawei.js2025;

import java.util.*;
import java.util.stream.Collectors;

/**
 * 最长密码
 */
public class Question13 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String strings = sc.nextLine();
        sc.close();

        List<String> list = Arrays.stream(strings.trim().split(" ")).collect(Collectors.toList());
        list.sort((e1, e2) -> e2.length() - e1.length());

        Set<String> set = new HashSet<>(list);


        for (String s : list) {
            boolean flag = true;
            for (int i = s.length() - 1; i >= 1; i--) {
                if (!set.contains(s.substring(0, i))) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                System.out.println(s);
                return;
            }
        }
    }
}
